﻿package mortal.game.view.heroArena.renderer
{
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.heroArena.view.*;
    import mortal.mvc.core.*;

    public class HeroArenaApplyResponseRenderer extends GCellRenderer
    {
        private var _roleName:GTextFiled;
        private var _levelCareer:GTextFiled;
        private var _yesBtn:GButton;
        private var _noBtn:GButton;
        private var _sArenaPlayer:SArenaBasePlayer;

        public function HeroArenaApplyResponseRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._roleName = UIFactory.gTextField("", 0, 15, 100, 20, this);
            this._roleName.htmlText = HTMLUtil.addLink("", GlobalStyle.colorLv);
            this._roleName.configEventListener(MouseEvent.CLICK, this.onLinkClickHandler);
            this._roleName.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._roleName.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            this._levelCareer = UIFactory.gTextField("", 90, 15, 160, 20, this, GlobalStyle.textFormatBai);
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41510), 0, 36, 256, 20, this));
            this._yesBtn = UIFactory.gButton(Language.getString(41511), 252, 12, 44, 22, this);
            this._noBtn = UIFactory.gButton(Language.getString(41512), 252, 35, 44, 22, this);
            this._yesBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._noBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this.pushUIToDisposeVec(UIFactory.bg(0, 62, 315, 2, this, ImagesConst.SplitLine));
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:String = null;
            super.data = param1;
            this._sArenaPlayer = param1 as SArenaBasePlayer;
            if (this._sArenaPlayer)
            {
                this._roleName.text = this._sArenaPlayer.name;
                _loc_2 = GameDefConfig.instance.getCarrer(this._sArenaPlayer.career);
                this._levelCareer.htmlText = "[" + HTMLUtil.addColor("Lv." + this._sArenaPlayer.level, GlobalStyle.colorHuang2) + "/" + HTMLUtil.addColor(_loc_2, GlobalStyle.colorLan) + "/" + HTMLUtil.addColor(Language.getString(41513) + this._sArenaPlayer.combat, GlobalStyle.colorHuang2) + "]";
                this._levelCareer.x = this._roleName.x + this._roleName.textWidth + 2;
            }
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            if (event.target == this._yesBtn)
            {
                GameProxy.copy.agreeJoinArenaTeam(this._sArenaPlayer.entityId);
                HeroArenaApplyResponseWin.instance.hide();
            }
            if (event.target == this._noBtn)
            {
                Cache.instance.heroArena.updateApplyList(this._sArenaPlayer, EUpdateType._EUpdateTypeDel);
                Dispatcher.dispatchEvent(new DataEvent(EventName.HeroArenaUpdateApplyList));
            }
            return;
        }// end function

        private function onLinkClickHandler(event:TextEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LookPlayerInfo, this._sArenaPlayer.entityId));
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.BUTTON);
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            CursorManager.hideFromButton();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._roleName.dispose();
            this._roleName = null;
            this._levelCareer.dispose();
            this._levelCareer = null;
            this._yesBtn.dispose();
            this._yesBtn = null;
            this._noBtn.dispose();
            this._noBtn = null;
            this._sArenaPlayer = null;
            return;
        }// end function

    }
}
